package com.example.kotlindemo

sealed class Result


class Success(val msg:String):Result()
class Error(val error: Throwable):Result()

//枚举
fun getResult(result: Result) = when (result){
    is Success -> result.msg
    is Error -> result.error.stackTrace
//    else -> throw IllegalAccessException()
}

fun main(){
    val map = mapOf("one" to 1,"one" to 1,"one" to 1)
//    println(map+Pair("four",4)+Pair("four",4))
    println(map- listOf("four"))

    when(val input = "abc"){
        in Regex("[0-9]") -> println("true")
        in Regex("[a-zA-Z]") -> println("true")
        in listOf("") -> println("")
    }

}

//自定义重载运算符

operator fun  Regex.contains(text:CharSequence):Boolean = this.containsMatchIn(text)


